package at.gv.bmwf.fons.model.ontology.static_impl;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.Resource;

import at.gv.bmwf.fons.model.ontology.CategorialFacet;
import at.gv.bmwf.fons.model.ontology.Facet;
import at.gv.bmwf.fons.model.ontology.StructuralFacet;

public abstract class StaticAbstractFacet extends StaticResource implements Facet {
	private final StaticAbstractFacet next;
	
	public StaticAbstractFacet (StaticAbstractFacet next) {
		super(next.getResource());
		this.next = next;
	}
	
	public StaticAbstractFacet (Resource resource) {
		super(resource);
		this.next = null;
	}
	
	@Override
	public Resource getResource() {
		return hasNext() ? next.getResource() : super.getResource();
	}

	@Override
	public Model getModel() {
		return hasNext() ? next.getModel() : super.getModel();
	}
	
	protected boolean hasNext() {
		return next != null;
	}
	
	protected StaticAbstractFacet getNext() {
		return next;
	}

	@Override
	public boolean hasCategory(Class<? extends CategorialFacet> categorialFacet) {
		return this.getClass().equals(categorialFacet);
	}

	@Override
	public boolean hasStructure(Class<? extends StructuralFacet> structuralFacet) {
		return this.getClass().equals(structuralFacet);
	}

}
